from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_admin.admin_permission import admin_permission_views
from meiduo_admin.brands import brand_views
from meiduo_admin.home import views
from meiduo_admin.user import user_views
from rest_framework.routers import DefaultRouter
from meiduo_admin.skus import skus_views
from meiduo_admin.spu import spus_views
from meiduo_admin.specs import spec_views
from meiduo_admin.image import image_views
from meiduo_admin.order import order_views
from meiduo_admin.permission import permission_views
from meiduo_admin.groups_permission import groups_permission_view
from meiduo_admin.channels import channels_views

urlpatterns = [
    # home
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^statistical/total_count/$', views.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$', views.UserIncrementView.as_view()),
    url(r'^statistical/day_active/$', views.UserDayActiveView.as_view()),
    url(r'^statistical/day_orders/$', views.UserDayOrdersView.as_view()),
    url(r'^statistical/month_increment/$', views.UserMonthIncrementView.as_view()),
    url(r'^statistical/goods_day_views/$', views.UseGoodsVisitCountView.as_view()),

    # user
    url(r'^users/$', user_views.UserView.as_view()),

    # 新增商品sku分类路由
    url(r'^skus/categories/$', skus_views.SKUCategoryView.as_view()),
    # 新增商品spu分类路由
    url(r'^goods/simple/$', skus_views.SKUGoodSimpleView.as_view()),

    # 新增商品spu规格选项路由goods/2/specs/
    url(r'^goods/(?P<spu_id>\d+)/specs/$', skus_views.SKUGoodSpecsView.as_view()),
    url(r'^goods/brands/simple/$', spus_views.SPUBrandSimpleView.as_view()),
    url(r'^goods/channel/categories/$', spus_views.SPUCategoryView.as_view()),
    url(r'^goods/channel/categories/(?P<category_id>\d+)/$', spus_views.SPUCategorySubView.as_view()),
    # 图片上传
    url(r'^goods/images/$', spus_views.SPUImageUploadView.as_view()),
    # 新增规格选项
    url(r'^goods/specs/simple/$', spec_views.SpecOptions.as_view()),
    # 新增图片
    url(r'^skus/simple/$', image_views.ImageViewSet.as_view({"get": "simple"})),
    # 新增权限permission/content_types/
    url(r'^permission/content_types/$', permission_views.PermissionContentView.as_view()),
    # 新增用户组
    url(r'^permission/simple/$', groups_permission_view.GroupsPermissionSimpleView.as_view()),
    #新增管理员用户组的权限列表
    url(r'^permission/groups/simple/$', admin_permission_views.AdminPermissionSimoleView.as_view()),
    #新增频道组
    url(r'^goods/categories/$',channels_views.ChnnelsCategoriesViewSet.as_view()),
    url(r'^goods/channel_types/$',channels_views.ChnnelsTypeViewSet.as_view()),

]

#11.品牌管理
router=DefaultRouter()
router.register(r'goods/brands',brand_views.GoodsBrandsView,base_name='brands')
urlpatterns += router.urls
# 10.管理圆permission/admins
router=DefaultRouter()
router.register(r'permission/admins',admin_permission_views.AdminPermissionView,base_name='admin')
urlpatterns += router.urls

# 9.频道管理goods/channels
router = DefaultRouter()
router.register(r'goods/channels', channels_views.GoodsChnnelsViewSet, base_name="channels")
urlpatterns += router.urls

# 8.用户管理permission/groups
router = DefaultRouter()
router.register(r'permission/groups', groups_permission_view.GroupsPermissionVietSet, base_name="groups")
urlpatterns += router.urls

# 7.权限管理/permission/perms/
router = DefaultRouter()
router.register(r'permission/perms', permission_views.PermissionViewsSet, base_name="permission")
urlpatterns += router.urls

# 6.订单管理
router = DefaultRouter()
router.register(r'orders', order_views.OrderViewSet, base_name="order")
urlpatterns += router.urls

# 5.图片管理路由
router = DefaultRouter()
router.register(r'skus/images', image_views.ImageViewSet, base_name="images")
urlpatterns += router.urls

# 4.规格选项表管理,要写在前面不然无法读取到
router = DefaultRouter()
router.register(r'specs/options', spec_views.SpecViewSet, base_name="options")
urlpatterns += router.urls

# 3.spu规格表,要写在前面不然无法读取到
router = DefaultRouter()
router.register(r'goods/specs', spec_views.SPUSpecViewSet, base_name="spuspecs")
urlpatterns += router.urls

# 1.商品视图集路由
routers = DefaultRouter()
routers.register(r'skus', skus_views.SKUViewSet, base_name='kk')
urlpatterns += routers.urls

# 2.spu管理视图集
router = DefaultRouter()
router.register(r'goods', spus_views.SPUViewSetview, base_name='spu')
urlpatterns += router.urls
